<?php

namespace App\Repositories\Order;

use Illuminate\Support\Facades\DB;
use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Repositories\Order\RefundDetailRepository;
use App\Models\Order\RefundDetail;
use App\Validators\Order\RefundDetailValidator;

/**
 * Class RefundDetailRepositoryEloquent.
 *
 * @package namespace App\Repositories\Order;
 */
class RefundDetailRepositoryEloquent extends BaseRepository implements RefundDetailRepository
{
    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return RefundDetail::class;
    }

    /**
    * Specify Validator class name
    *
    * @return mixed
    */
    public function validator()
    {

        return RefundDetailValidator::class;
    }


    /**
     * Boot up the repository, pushing criteria
     */
    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }

    /**
     * @author Min
     * @param $order_id
     * @param $goods_id
     * @return mixed
     */
    public function getRefundDetailSumByGoodsId($order_id, $goods_id)
    {
        $where = array(
            'order_id' => $order_id,
            'goods_id' => $goods_id
        );

        return $this->findWhere($where)->count();
    }
    
}
